/**
 * 
 */
package cc.dogtailflower.framework.util;

import com.fasterxml.jackson.databind.ObjectMapper;

import cc.dogtailflower.framework.exception.AppException;

/**
 * @author cc
 *
 */
public class JsonUtil {

	private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
	/*
	 * 普通对象转JSON
	 */
	public static <T> String toJson(T obj){
		String json;
		try{
			json = OBJECT_MAPPER.writeValueAsString(obj);
		}catch(Exception e){
			e.printStackTrace();
			throw new AppException(e.getMessage());
		}
		return json;
	}
}
